#!/usr/bin/env python 3.9
# -*- coding = utr-8 -*-
'''
@Project: DouBan
@File: testUrllib_TIMEOUT.py
@IDE: PyCharm
@Author: Simon
@Date: 5/3/21  12:51 AM
'''

# 超时处理
import urllib.request
from urllib.request import urlopen, Request

url = 'http://httpbin.org/get'

try:
    aa = urllib.request.urlopen(url, timeout=0.01)
    print(aa.read().decode("utf-8"))
except urllib.error.URLError as e:
    print("Time out!!")